package com.design.proxy.dynamicproxy;

import sun.misc.ProxyGenerator;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @auther LiZiBa
 * @date 2020/8/9 12:36
 * @description:
 **/
public class Test {

    public static void main(String[] args) {

        JDKMeipo jdkMeipo = new JDKMeipo();
        IPerson zhangsan = jdkMeipo.getInstance(new Zhangsan());
        zhangsan.findLove();

        byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy0", new Class[]{IPerson.class});
        try (FileOutputStream fos = new FileOutputStream("F://$Proxy0")) {

            fos.write(bytes);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
